var listColumns = [[
    {field: "contactid", title: "联络ID", align: "center", width: 200},
    {field: "oriAni", title: "分机号码", align: "center", width: 80},
    {field: "leaveType", title: "留言类型", align: "center", width: 80},
    {field: "startTime", title: "开始时间", align: "center", width: 200},
    {
        field: "fileName", title: "试听", align: "center", width: 295, formatter: function (value) {
            return '<audio preload="auto" src="http://172.16.1.101:9999/file-server?fileName='+value+'"></audio>';
            // return '<audio preload="auto" src="' + value + '"></audio>';
        }
    }
]];

layui.config({
    base: "../static/agent-ui/js/"
});

$.fn.toJSON = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        var name = this.name;
        var value = this.value;
        var paths = this.name.split(".");
        var len = paths.length;
        var obj = o;
        $.each(paths, function (i, e) {
            if (i == len - 1) {
                if (obj[e]) {
                    if (!obj[e].push) {
                        obj[e] = [obj[e]];
                    }
                    obj[e].push(value || '');
                } else {
                    obj[e] = value || '';
                }
            } else {
                if (!obj[e]) {
                    obj[e] = {};
                }
            }
            obj = o[e];
        });
    });
    return o;
};

layui.use(["laypage", "layer", "validator", "tools", "form", "select", "laydate", "upload"], function () {
    var form = layui.form;
    var date = layui.laydate;
    date.render({
        elem: '#ringTime',
        type: 'datetime',
        range: true
    });


    var layer=layui.layer;
    $(function () {
        $('#list').datagrid({
            columns: listColumns,
            fitColumns: false,
            fit: true,
            singleSelect: true,
            pagination: true,
            pageSize: 30,
            pageList: [30, 50, 100, 1000],
            toolbar: '#receivedListHeader',
            method: 'get',
            url: ctx +'/leaveMsg/list',
            onLoadSuccess: function () {
                audiojs.events.ready(function () {
                    audiojs.createAll();
                });
            }
        });
    });

    /*$('#search_submit').on('click', function () {
        $('#list').datagrid('load', $('#search_form').toJSON());
    });*/

});







